<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>正则表达式</title>
    <script>
        /*
            - 创建
                    1.var reg = new RegExp("正则表达式");
                    2.var reg = /正则表达式/;

            - 方法
        */
        var reg = new RegExp("\\w{6,12}");
        var reg2 = /\w{6,12}/;
        alert(reg);
        alert(reg2);
        var username = "Gnar";
        var flag = reg2.test(username);
        alert(flag);
    </script>
</head>
<body>

</body>
</html>